are "obviously" leaks and a cleanup upportunity.
egrep -- '->(rte_name|rte_desc|rte_url|icon|icon_descr|rte_name|rte_desc|notes|shortname|description) = xstrdup' *.cca
We've eliminated 58% of the calls to xstrdup that we had in 1.4.4..
#endif
if (rec->image_name) {
- wpt_tmp->icon_descr = xstrdup(rec->image_name);
+ wpt_tmp->icon_descr = rec->image_name;
} else if (FindIconByGuid(&rec->guid, &icon)) {
wpt_tmp->icon_descr = icon;
}
}
if (remaining) {
track = route_head_alloc();
- track->rte_name = xstrdup(PRESTRKNAME);
- track->rte_desc = xstrdup("Brauniger-IQ Barograph");
+ track->rte_name = PRESTRKNAME;
+ track->rte_desc = "Brauniger-IQ Barograph";
track_add_head(track);
} else {
warning(MYNAME ": No barograph recorded for this flight\n");
line++;
cin = lrtrim(buff);
if (*cin != '\0') {
-#if NEW_STRINGS
wpt->notes = QString::fromLatin1(cin);
-#else
- wpt->notes = xstrdup(cin);
-#endif
}
} else if (strcmp(cin + 2, "end") == 0) {
data = 1;
track = route_head_alloc();
track_add_head(track);
} else if (strncmp(name, "NAME:", 5) == 0) {
-#if NEW_STRINGS
wpt->shortname = QString::fromLatin1(((char*)&name) + 5);
-#else
- wpt->shortname = xstrdup(((char*)&name) + 5);
-#endif
}
pow = strrchr(cin, '^');
// wp->icon_descr = wp->icon_descr;
// }
if (p->name_size && p->name[0]) {
- wp->description = xstrdup(p->name);
+ wp->description = p->name;
}
s = p->name + p->name_size;
if (le_readu16(s) && s[2]) {
char* pp;
if (waypt_empty_gc_data(wp)) {
-#if NEW_STRINGS
notes = xstrdup(wp->notes);
if (notes == NULL && wp->description.isEmpty() && wp->shortname != wp->description) {
-#else
- notes = wp->notes;
- if (notes == NULL && wp->description && strcmp(wp->shortname, wp->description)) {
-#endif
notes = xstrdup(wp->description);
}
if (notes) {
// process track messages
p = (const msg_track_header_t*) msg_array[0].data;
if (le_readu16(p->comment_size)) {
- track->rte_desc = xstrdup(p->comment);
+ track->rte_desc = p->comment;
}
track->line_color.bbggrr = track_color(p->color[0]);
n_point = le_readu32(p->total_points);
const msg_track_header_t* p = (msg_track_header_t*) msg_array[i].data;
if (le_readu32(p->total_points)) {
track_array[i] = route_head_alloc();
- track_array[i]->rte_name = xstrdup(p->name);
+ track_array[i]->rte_name = p->name;
}
} else {
fatal(MYNAME ": unexpected message %x while reading track headers\n", id);
wp->latitude = delbin_rad2deg(le_read32(p->point[i].latitude));
wp->longitude = delbin_rad2deg(le_read32(p->point[i].longitude));
sprintf(buf, "SHP%03u", j);
- wp->shortname = xstrdup(buf);
+ wp->shortname = buf;
}
*wp_array_i = j;
}
gbfile* fd = gbfopen(NULL, "w", MYNAME);
waypoint* wp = waypt_new();
if (p->name[0]) {
- wp->shortname = xstrdup(p->name);
+ wp->shortname = p->name;
}
// give these a higher priority than the shape points
wp->route_priority = 1;
unsigned id = message_get_id(&msg_array[i]);
if (id == MSG_ROUTE_HEADER_OUT) {
route_array[i] = route_head_alloc();
- route_array[i]->rte_name = xstrdup(((msg_route_header_t*)msg_array[i].data)->name);
+ route_array[i]->rte_name = ((msg_route_header_t*)msg_array[i].data)->name;
} else {
fatal(MYNAME ": unexpected message %x while reading route headers\n", id);
}
wp->course /= 100;
wp->wpt_flags.course = 1;
decode_sat_fix(wp, p->fix_status);
- wp->shortname = xstrdup("Position");
+ wp->shortname = "Position";
return wp;
}
strftime(buf, 4096, "DG-100 tracklog (%Y/%m/%d %H:%M:%S)",
gmtime(&creation_time));
*track = route_head_alloc();
- (*track)->rte_name = xstrdup(buf);
- (*track)->rte_desc = xstrdup("DG-100 GPS tracklog data");
+ (*track)->rte_name = buf;
+ (*track)->rte_desc = "DG-100 GPS tracklog data";
track_add_head(*track);
}
waypoint* wpt = waypt_new();
wpt->latitude = gps_save_lat;
wpt->longitude = gps_save_lon;
- wpt->shortname = xstrdup("Position");
+ wpt->shortname = "Position";
if (gps_save_time) {
wpt->SetCreationTime(gps_save_time);
}
for (i = 0; i < n; i++) {
waypoint* wpt_tmp = waypt_new();
- wpt_tmp->shortname = xstrdup(way[i]->ident);
- wpt_tmp->description = xstrdup(way[i]->cmnt);
-#if NEW_STRINGS
+ wpt_tmp->shortname = way[i]->ident;
+ wpt_tmp->description = QString(way[i]->cmnt).simplified();
wpt_tmp->shortname = wpt_tmp->shortname.simplified();
wpt_tmp->description = wpt_tmp->description.simplified();
-#else
- rtrim(wpt_tmp->shortname);
- rtrim(wpt_tmp->description);
-#endif
wpt_tmp->longitude = way[i]->lon;
wpt_tmp->latitude = way[i]->lat;
if (gps_waypt_type == 103) {
if (trk_head == NULL || array[i]->ishdr) {
trk_head = route_head_alloc();
trk_head->rte_num = trk_num;
- trk_head->rte_name = xstrdup(trk_name);
+ trk_head->rte_name = trk_name;
trk_num++;
track_add_head(trk_head);
}
wpt->altitude = array[i]->alt;
wpt->heartrate = array[i]->heartrate;
wpt->cadence = array[i]->cadence;
- wpt->shortname = xstrdup(array[i]->trk_ident);
+ wpt->shortname = array[i]->trk_ident;
wpt->SetCreationTime(array[i]->Time);
wpt->wpt_flags.is_split = checkWayPointIsAtSplit(wpt, laps,
nlaps);
rte_head = route_head_alloc();
route_add_head(rte_head);
if (csrc) {
- rte_head->rte_name = xstrdup(csrc);
+ rte_head->rte_name = csrc;
}
} else {
if (array[i]->islink) {
/*For D906, we would like to use the track_index in the last packet instead...*/
trk_head->rte_num = ++trk_num;
strftime(tbuf, 32, "%Y-%m-%dT%H:%M:%SZ", stmp);
- trk_head->rte_name = xstrdup(tbuf);
+ trk_head->rte_name = tbuf;
track_add_head(trk_head);
wpt = waypt_new();
wpt->microseconds = 0;
sprintf(tbuf, "#%d-0", index);
- wpt->shortname = xstrdup(tbuf);
+ wpt->shortname = tbuf;
sprintf(tbuf, "D:%f Cal:%d MS:%f AH:%d MH:%d AC:%d I:%d T:%d",
array[i]->total_distance, array[i]->calories, array[i]->max_speed, array[i]->avg_heart_rate,
array[i]->max_heart_rate, array[i]->avg_cadence, array[i]->intensity, array[i]->trigger_method);
- wpt->description = xstrdup(tbuf);
+ wpt->description = tbuf;
track_add_wpt(trk_head, wpt);
}
/*Allow even if no correct location, no skip if invalid */
wpt->microseconds = 10000*(array[i]->total_time % 100);
/*Add fields with no mapping in the description */
sprintf(tbuf, "#%d", index);
- wpt->shortname = xstrdup(tbuf);
+ wpt->shortname = tbuf;
sprintf(tbuf, "D:%f Cal:%d MS:%f AH:%d MH:%d AC:%d I:%d T:%d (%f,%f)",
array[i]->total_distance, array[i]->calories, array[i]->max_speed, array[i]->avg_heart_rate,
array[i]->max_heart_rate, array[i]->avg_cadence, array[i]->intensity, array[i]->trigger_method,
array[i]->begin_lon, array[i]->begin_lat);
- wpt->description = xstrdup(tbuf);
+ wpt->description = tbuf;
track_add_wpt(trk_head, wpt);
}
pvt2wpt(pvt, wpt);
GPS_Pvt_Del(&pvt);
- wpt->shortname = xstrdup("Position");
+ wpt->shortname = "Position";
if (gps_errno && posn_status) {
posn_status->request_terminate = 1;
trk_head = route_head_alloc();
track_add_head(trk_head);
}
-#if 0
-void gl_trk_ident(xg_string args, const QXmlStreamAttributes* unused)
-{
- trk_head->rte_name = xstrdup(args);
-}
-#endif
void gl_trk_pnt_s(xg_string args, const QXmlStreamAttributes* unused)
{
void gl_trk_lat(xg_string args, const QXmlStreamAttributes* unused)
{
-#if NEW_STRINGS
wpt_tmp->latitude = args.toDouble();
-#else
- wpt_tmp->latitude = atof(args);
-#endif
}
void gl_trk_long(xg_string args, const QXmlStreamAttributes* unused)
{
-#if NEW_STRINGS
wpt_tmp->longitude = args.toDouble();
-#else
- wpt_tmp->longitude = atof(args);
-#endif
}
void gl_trk_alt(xg_string args, const QXmlStreamAttributes* unused)
{
-#if NEW_STRINGS
wpt_tmp->altitude = args.toDouble();
-#else
- wpt_tmp->altitude = atof(args);
-#endif
}
ignr_descr(xg_string args, const QXmlStreamAttributes* attrv)
{
ignr_xml_error((track == NULL));
-#if NEW_STRINGS
track->rte_desc = args;
-#else
- if ((args != NULL) && (strlen(args) > 0)) {
- track->rte_desc = xstrdup(args);
- }
-#endif
}
static void
if (!oname.isEmpty()) {
lmx_write_xml(0x48, oname, 3); // name
}
-#if NEW_STRINGS
if (!wpt->description.isEmpty()) {
-#else
- if (wpt->description) {
-#endif
lmx_write_xml(0x49, wpt->description, 3); // description
}
lmx_start_tag(0x4A, 3); // coordinates
static void
lmx_lm_lat(xg_string args, const QXmlStreamAttributes* unused)
{
-#if NEW_STRINGS
wpt_tmp->latitude = args.toDouble();
-#else
- wpt_tmp->latitude = atof(args);
-#endif
}
static void
lmx_lm_lon(xg_string args, const QXmlStreamAttributes* unused)
{
-#if NEW_STRINGS
wpt_tmp->longitude = args.toDouble();
-#else
- wpt_tmp->longitude = atof(args);
-#endif
}
static void
lmx_lm_alt(xg_string args, const QXmlStreamAttributes* unused)
{
-#if NEW_STRINGS
wpt_tmp->altitude = args.toDouble();
-#else
- wpt_tmp->altitude = atof(args);
-#endif
}
static void
lmx_lm_name(xg_string args, const QXmlStreamAttributes* unused)
{
-#if NEW_STRINGS
wpt_tmp->shortname = args;
-#else
- wpt_tmp->shortname = xstrdup(args);
-#endif
}
static void
lmx_lm_desc(xg_string args, const QXmlStreamAttributes* unused)
{
-#if NEW_STRINGS
wpt_tmp->description = args;
-#else
- wpt_tmp->description = xstrdup(args);
-#endif
}
static void
mps_depth = wpt->depth;
}
QString src;
-#if NEW_STRINGS
if (!wpt->description.isEmpty()) {
src = wpt->description;
}
if (!wpt->notes.isEmpty()) {
src = wpt->notes;
}
-#else
- if (wpt->description) {
- src = wpt->description;
- }
- if (wpt->notes) {
- src = wpt->notes;
- }
-#endif
QString ident = global_opts.synthesize_shortnames ?
mkshort(mkshort_handle, src) :
CSTRc(wpt->shortname);
icon = mps_converted_icon_number(icon, mps_ver, MAPSOURCE);
/* two NULL (0x0) bytes at end of each string */
-#if NEW_STRINGS
ascii_description = xstrdup(wpt->description);
-#else
- ascii_description = wpt->description ? xstrdup(wpt->description) : xstrdup("");
-#endif
reclen = ident.length() + strlen(ascii_description) + 2;
if ((mps_ver == 4) || (mps_ver == 5)) {
/* v4.06 & V5.0*/
gbfwrite(zbuf, 2, 1, mps_file); /* unknown */
if ((mps_ver == 4) || (mps_ver == 5)) {
gbfwrite(zbuf, 4, 1, mps_file); /* unknown */
-#if NEW_STRINGS
if (!wpt->notes.isEmpty()) {
-#else
- if (wpt->notes) {
-#endif
gbfputs(wpt->notes, mps_file);
}
gbfwrite(zbuf, 1, 1, mps_file); /* string termination */
fprintf(stderr, "mps_route_r: reached the point we never should\n");
#endif
thisWaypoint = waypt_new();
- thisWaypoint->shortname = xstrdup(wptname);
+ thisWaypoint->shortname = wptname;
thisWaypoint->latitude = GPS_Math_Semi_To_Deg(lat);
thisWaypoint->longitude = GPS_Math_Semi_To_Deg(lon);
thisWaypoint->altitude = mps_altitude;
} else {
/* should never reach here, but we do need a fallback position */
thisWaypoint = waypt_new();
- thisWaypoint->shortname = xstrdup(wptname);
+ thisWaypoint->shortname = wptname;
thisWaypoint->latitude = GPS_Math_Semi_To_Deg(lat);
thisWaypoint->longitude = GPS_Math_Semi_To_Deg(lon);
thisWaypoint->altitude = mps_altitude;
}
QString src;
-#if NEW_STRINGS
if (!testwpt->description.isEmpty()) {
-#else
- if (testwpt->description) {
-#endif
src = testwpt->description;
}
-#if NEW_STRINGS
if (!testwpt->notes.isEmpty()) {
-#else
- if (testwpt->notes) {
-#endif
src = testwpt->notes;
}
QString ident = global_opts.synthesize_shortnames ?
}
/* route name */
-#if NEW_STRINGS
if (rte->rte_name.isEmpty()) {
-#else
- if (!rte->rte_name) {
-#endif
sprintf(hdr, "Route%04x", (unsigned) uniqueValue);
rname = xstrdup(hdr);
} else {
}
QString src;
-#if NEW_STRINGS
if (!rtewpt->description.isEmpty()) {
src = rtewpt->description;
}
if (!rtewpt->notes.isEmpty()) {
src = rtewpt->notes;
}
-#else
- if (rtewpt->description) {
- src = rtewpt->description;
- }
- if (rtewpt->notes) {
- src = rtewpt->notes;
- }
-#endif
QString ident = global_opts.synthesize_shortnames ?
mkshort(mkshort_handle, src) :
CSTRc(rtewpt->shortname);
}
/* track name */
-#if NEW_STRINGS
if (trk->rte_name.isEmpty()) {
-#else
- if (!trk->rte_name) {
-#endif
sprintf(hdr, "Track%04x", (unsigned) uniqueValue);
tname = xstrdup(hdr);
} else {
}
if (*cend++) {
-#if NEW_STRINGS
wpt->notes = QString::fromLatin1(cend);
-#else
- wpt->notes = xstrdup(cend);
-#endif
}
if (wpt->HasUrlLink()) {
DBG((sobj, "url = \"%s\"\n", wpt->url));
}
} else if (*str) {
-#if NEW_STRINGS
wpt->notes = QString::fromLatin1(str);
-#else
- wpt->notes = xstrdup(str);
-#endif
}
xfree(str);
-#if NEW_STRINGS
if (!wpt->notes.isEmpty()) {
-#else
- if (wpt->notes) {
-#endif
DBG((sobj, "notes = \"%s\"\n", wpt->notes));
}
wpt->latitude = wpt2->latitude;
wpt->longitude = wpt2->longitude;
- wpt->shortname = (wpt2->shortname);
+ wpt->shortname = wpt2->shortname;
- wpt->description = (wpt2->description);
+ wpt->description = wpt2->description;
wpt->notes = (wpt2->notes);
if (wpt2->HasUrlLink()) {
UrlLink l = wpt2->GetUrlLink();
- wpt->notes = xstrdup(l.url_.toUtf8().data());
+ wpt->notes = l.url_;
}
wpt->proximity = wpt2->proximity;
/* put the data in the waypoint structure */
ng_convert_datum(wpt_tmp);
-#if NEW_STRINGS
wpt_tmp->shortname = codec->toUnicode(WPNC.strName);
wpt_tmp->description = codec->toUnicode(strComment);
-#else
- wpt_tmp->shortname = xstrdup(WPNC.strName);
- wpt_tmp->description = xstrdup(strComment);
-#endif
if (process_rte) {
route_add_wpt(rte_head, wpt_tmp);
return waypt1->latitude == waypt2->latitude &&
waypt1->longitude == waypt2->longitude &&
waypt1->altitude == waypt2->altitude &&
-#if NEW_STRINGS
waypt1->shortname == waypt2->shortname;
-#else
- strcmp(waypt1->shortname, waypt2->shortname) == 0;
-#endif
}
unsigned
route_head* route;
route = (route_head*) hd;
-#if NEW_STRINGS
grp = route->rte_name.toInt();
-#else
- grp = atoi(route->rte_name);
-#endif
i = 0;
while (i<groups_cnt && groups[i].group!=grp) {
i++;
} else {
strcpy(name,groups[i].name);
}
-#if NEW_STRINGS
route->rte_name = name;
-#else
- route->rte_name = (char*) xrealloc(route->rte_name,(strlen(name)+1)*sizeof(char));
- strcpy(route->rte_name,name);
-#endif
}
static void ovl_read(void)
case 3: // Linie
route_head = route_head_alloc();
route_head->rte_num = sym_cnt;
- route_head->rte_name = xstrdup(pstr); /* use group-number for the moment */
+ route_head->rte_name = pstr; /* use group-number for the moment */
route_add_head(route_head);
break;
}
wpt->latitude = aktY;
wpt->longitude = aktX;
wpt->altitude = 0.0;
- wpt->shortname = strdup(aktPath);
+ wpt->shortname = aktPath;
waypt_add(wpt);
break;
#endif
ozi_openfile(ozi_ofname);
gbfprintf(file_out, ozi_trk_header,
altunit == 'f' ? "Feet" : "Meters",
-#if NEW_STRINGS
rte->rte_name.isEmpty() ? "ComplimentsOfGPSBabel" : CSTRc(rte->rte_name));
-#else
- rte->rte_name ? CSTRc(rte->rte_name) : "ComplimentsOfGPSBabel");
-#endif
}
track_out_count++;
gbfprintf(file_out, "R,%d,%s,%s,\r\n",
route_out_count,
-#if NEW_STRINGS
CSTRc(rte->rte_name),
CSTRc(rte->rte_desc));
-#else
- rte->rte_name ? CSTRc(rte->rte_name) : "",
- rte->rte_desc ? CSTRc(rte->rte_desc) : "");
-#endif
}
static void
gbfprintf(file_out, "W,%d,,%d,%s,%.6f,%.6f,%s,0,1,3,0,65535,%s,0,0\r\n",
route_out_count,
route_wpt_count,
-#if NEW_STRINGS
CSTR(waypointp->shortname),
-#else
- waypointp->shortname ? CSTRc(waypointp->shortname) : "",
-#endif
waypointp->latitude,
waypointp->longitude,
ozi_time,
-#if NEW_STRINGS
CSTR(waypointp->description));
-#else
- waypointp->description ? CSTRc(waypointp->description) : "");
-#endif
}
while (s) {
field ++;
if (field == 4) {
- trk_head->rte_name = xstrdup(lrtrim(s));
+ trk_head->rte_name = QString(s).trimmed();
}
s = csv_lineparse(NULL, ",", "", linecount);
}
static int index = 0;
double alt;
char ozi_time[16];
-#if NEW_STRINGS
QString description;
QString shortname;
-#else
- char* description;
- char* shortname;
-#endif
int faked_fsdata = 0;
ozi_fsdata* fs = NULL;
int icon = 0;
} else {
alt = wpt->altitude * alt_scale;
}
-#if NEW_STRINGS
if ((wpt->shortname.isEmpty()) || (global_opts.synthesize_shortnames)) {
if (!wpt->description.isEmpty()) {
-#else
- if ((!wpt->shortname) || (global_opts.synthesize_shortnames)) {
- if (wpt->description) {
-#endif
if (global_opts.synthesize_shortnames) {
shortname = mkshort_from_wpt(mkshort_handle, wpt);
} else {
} else {
shortname = csv_stringclean(wpt->shortname, BADCHARS);
}
-#if NEW_STRINGS
if (wpt->description.isEmpty()) {
if (!shortname.isEmpty()) {
-#else
- if (!wpt->description) {
- if (shortname) {
-#endif
description = csv_stringclean(shortname, BADCHARS);
} else {
description = xstrdup("");
gbfprintf(file_out,"%d,", 0);
}
gbfprintf(file_out, "%.0f,%d,%d,%d\r\n", alt, 6, 0, 17);
-#if NEW_STRINGS
-#else
- xfree(description);
- xfree(shortname);
-#endif
if (faked_fsdata) {
xfree(fs);
if (routename) {
rte_head = route_head_alloc();
- rte_head->rte_name = xstrdup(routename);
+ rte_head->rte_name = routename;
route_add_head(rte_head);
}
case SHPT_ARC: {
int j;
route_head* routehead = route_head_alloc();
- routehead->rte_name = xstrdup(name);
+ routehead->rte_name = name;
route_add_head(routehead);
for (j = 0; j < shp->nVertices; j++) {
wpt = waypt_new();
break;
case 2:
-#if NEW_STRINGS
wpt->shortname = QString::fromLatin1(c);
-#else
- wpt->shortname = xstrdup(c);
-#endif
break;
case 3:
if (current_target == 'T') {
current_trk = route_head_alloc();
track_add_head(current_trk);
-#if NEW_STRINGS
if (!rte->rte_name.isEmpty()) {
-#else
- if (rte->rte_name && *rte->rte_name) {
-#endif
xasprintf(¤t_trk->rte_desc, "Generated from route %s", CSTRc(rte->rte_name));
- current_trk->rte_name = xstrdup(rte->rte_name); /* name the new trk */
+ current_trk->rte_name = rte->rte_name; /* name the new trk */
}
}
}
if (current_target == 'R') {
current_rte = route_head_alloc();
route_add_head(current_rte);
-#if NEW_STRINGS
if (!trk->rte_name.isEmpty()) {
current_rte->rte_desc = "Generated from track ";
current_rte->rte_desc += trk->rte_name;
current_rte->rte_name = trk->rte_name; /* name the new rte */
}
-#else
- if (trk->rte_name && *trk->rte_name) {
- xasprintf(¤t_rte->rte_desc, "Generated from track %s", CSTRc(trk->rte_name));
- current_rte->rte_name = xstrdup(trk->rte_name); /* name the new rte */
- }
-#endif
}
}